package net.homeip.mmhg.security;

import net.homeip.mmhg.domain.Team;

import org.springframework.security.GrantedAuthority;
import org.springframework.security.GrantedAuthorityImpl;
import org.springframework.security.userdetails.User;


/**
 * 
 *
 * @author ilya gerasimov
 */
@SuppressWarnings("serial")
public class Team2UserDetailsAdapter extends User {
	
	private Team team;
	
	public Team2UserDetailsAdapter(Team team) {
		super(team.getName(),
			  team.getPassword(), 
			  true, 
			  true, 
			  true, 
			  true, 
			  new GrantedAuthority[] {
				new GrantedAuthorityImpl("ROLE_" + team.getRole().getName())
			  } 
		);
		this.team = team;
	}

	public Team getTeam() {
		return team;
	}
}
